#!/bin/bash
shellExit()
{
if [ $1 -eq 1 ]; then
    printf "\nfailed!!!\n\n"
    exit 1
fi
}

printf "\nRegenerating file\n\n"
time go run -v ./cmd/mysqlmd/main.go  -addr $1 -user $2 -pass $3 -name $4 -tables $5
shellExit $?

printf "\ncreate curd code : \n"
# 定义下划线命名的变量  
underscore_name=$5  
# 将下划线替换为驼峰的连接符（连字符）  
camel_name=$(echo $underscore_name | tr '_' ' ')  
# 将每个单词的首字母大写  
camel_name=$(echo $camel_name | sed 's/\b\(.\)/\u\1/g')  
# 将空格去掉
camel_name=${camel_name// /}
echo $camel_name
time go run -v ./cmd/gormgen/main.go -structs $camel_name -input ./internal/repository/mysql/$5 
shellExit $?

printf "\nDone.\n\n"
